//author:jxx
//此处是对表单的方法，组件，权限操作按钮等进行任意扩展(方法扩展可参照SellOrder.js)
let extension = {
    components: {//动态扩充组件或组件路径
        //表单header、content、footer对应位置扩充的组件
        gridHeader:'',//{ template: "<div>扩展组xx件</div>" },
        gridBody: '',
        gridFooter: '',
        //弹出框(修改、编辑、查看)header、content、footer对应位置扩充的组件
        modelHeader: '',
        modelBody: '',
        modelFooter: ''
    },
    buttons: {view: [], box:[],  detail:[]},//扩展的按钮
    methods: {//事件扩展
       onInit() {
        this.maxBtnLength = 5;
        this.columns.push({
            title: '操作',
            fixed: 'right',
            width: 140,
            render: (h, { row, column, index }) => {
                return h(
                    "div", { style: {} }, [
                        h(
                            "a", {
                                props: {},
                                style: {},
                                on: {
                                    click: (e) => {
                                        //this.$Message.info(row.accountsReceivable);
                                        // e.stopPropagation()
                                        //console.log(this.$refs.gridHeader)
                                        this.linkData(row);
                                    }
                                }
                            },
                            "编辑"
                        ),
                        
                    ])
            }
        })
       },
       getFormOption(field) {
        let option;
        this.editFormOptions.forEach(x => {
            x.forEach(item => {
                if (item.field == field) {
                    option = item;
                }
            })
        })
        return option;
        },
       rowClick({ row, column, event }) { //查询界面table点击行选中当前行
        //console.log(row,column,event);
       
        this.$refs.table.$refs.table.toggleRowSelection(row);
        
        return true;
       },
       modelOpenAfter() {
        //获取当前弹出框是新建还是编辑状态
        let isEDIT = this.currentAction == this.const.EDIT;
        var selectOption = this.getFormOption('refundName');  
        if(!isEDIT) {
            selectOption.onInput = (val) => {    
            this.editFormFields.refundCode=this.base.chineseToPinYin(val);
            }
        } 
        var Code = this.getFormOption('refundName');
        this.$set(Code, "disabled",isEDIT)

        var isRefundable = this.getFormOption('isRefundable');
        isRefundable.onChange = (val, item) => {    
            console.log(val) 
            if(val==1){
                var autoEnd = this.getFormOption('autoEnd');
                this.$set(autoEnd, "disabled", false)
                //this.$set(autoEnd, "required", true)
                var isAutoEnd = this.getFormOption('isAutoEnd');
                this.$set(isAutoEnd, "disabled", false)
                //this.$set(isAutoEnd, "required", true)
                var isRefundReview = this.getFormOption('isRefundReview');
                this.$set(isRefundReview, "disabled", false)
               // this.$set(isRefundReview, "required", true)
                var reviewTime = this.getFormOption('reviewTime');
                this.$set(reviewTime, "disabled", false)
                //this.$set(reviewTime, "required", true)
                var isExpirationRefundable = this.getFormOption('isExpirationRefundable');
                this.$set(isExpirationRefundable, "disabled", false)
                //this.$set(isExpirationRefundable, "required", true)
                var refundAtLatest = this.getFormOption('refundAtLatest');
                this.$set(refundAtLatest, "disabled", false)
                //this.$set(refundAtLatest, "required", true)
                var refundCalendar = this.getFormOption('refundCalendar');
                this.$set(refundCalendar, "disabled", false)
               // this.$set(refundCalendar, "required", true)
                var remark = this.getFormOption('remark');
                this.$set(remark, "disabled", false)
                //this.$set(remark, "required", true)
            }else{
                var autoEnd = this.getFormOption('autoEnd');
                this.$set(autoEnd, "disabled", true)
                this.$set(autoEnd, "required", false)
                var isAutoEnd = this.getFormOption('isAutoEnd');
                this.$set(isAutoEnd, "disabled", true)
                this.$set(isAutoEnd, "required", false)
                var isRefundReview = this.getFormOption('isRefundReview');
                this.$set(isRefundReview, "disabled", true)
                this.$set(isRefundReview, "required", false)
                var reviewTime = this.getFormOption('reviewTime');
                this.$set(reviewTime, "disabled", true)
                this.$set(reviewTime, "required", false)
                var isExpirationRefundable = this.getFormOption('isExpirationRefundable');
                this.$set(isExpirationRefundable, "disabled", true)
                this.$set(isExpirationRefundable, "required", false)
                var refundAtLatest = this.getFormOption('refundAtLatest');
                this.$set(refundAtLatest, "disabled", true)
                this.$set(refundAtLatest, "required", false)
                var refundCalendar = this.getFormOption('refundCalendar');
                this.$set(refundCalendar, "disabled", true)
                this.$set(refundCalendar, "required", false)
                var remark = this.getFormOption('remark');
                this.$set(remark, "disabled", true)
                this.$set(remark, "required", false)
            }
         }
         //是否自动完结
         var isAutoEnd = this.getFormOption('isAutoEnd');
         isAutoEnd.onChange = (val, item) => {    
            console.log(val) 
            if(val==1){
                var autoEnd = this.getFormOption('autoEnd');
                this.$set(autoEnd, "disabled", false)
                
            }else{
                    var autoEnd = this.getFormOption('autoEnd');
                    this.$set(autoEnd, "disabled", true)
                    this.$set(autoEnd, "required", false)
            }
        }
        //是否审核
        var isRefundReview = this.getFormOption('isRefundReview');
        isRefundReview.onChange = (val, item) => {    
            console.log(val) 
            if(val==1){
                var reviewTime = this.getFormOption('reviewTime');
                this.$set(reviewTime, "disabled", false)
                
            }else{
                    var reviewTime = this.getFormOption('reviewTime');
                    this.$set(reviewTime, "disabled", true)
                    this.$set(reviewTime, "required", false)
            }
        }
         //过期是否可退
         var isExpirationRefundable = this.getFormOption('isExpirationRefundable');
         isExpirationRefundable.onChange = (val, item) => {    
             console.log(val) 
             if(val==1){
                 var refundAtLatest = this.getFormOption('refundAtLatest');
                 this.$set(refundAtLatest, "disabled", false)
                 
             }else{
                     var refundAtLatest = this.getFormOption('refundAtLatest');
                     this.$set(refundAtLatest, "disabled", true)
                     this.$set(refundAtLatest, "required", false)
             }
         }
       }
    }
};
export default extension;